package com.zkadmin.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "sys_resource")
public class SysResource extends AuditorAndVersionEntity {
	private static final long serialVersionUID = 8367366747055624091L;
	@Column(unique = true, nullable = false, length = 50)
	private String name;
	@Column(unique = true, nullable = false, length = 50)
	private String permission;
	@Column(unique = true, nullable = false, length = 12)
	private String code;

	@ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "resources")
	private Set<SysRole> roles = new HashSet<SysRole>();

	public SysResource() {
	}

	public SysResource(String name, String code, String permission) {
		this.name = name;
		this.code = code;
		this.permission = permission;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Set<SysRole> getRoles() {
		return roles;
	}

	public void setRoles(Set<SysRole> roles) {
		this.roles = roles;
	}

}
